using System;
using SharpMud.Net;
using SharpMud.Server.Systems.Net;
using SharpMud.Server.Systems.Metadata;

namespace SharpMud.Server.Systems.Net.Intermud3
{
    [Name("I3System")]
    [Version("0.8")]
    [Guid("{EBB21086-DD40-A505-CAC8-BD9F011C8601}")]
    public class I3System : PulsarServerSystem, INetworkSystem
    {
        private I3SystemConfiguration _Configuration;

        #region Constructors
        protected I3System()
        {

        }

        public I3System(I3SystemConfiguration configuration)
        {
            _Configuration = configuration;
        }
        #endregion

        #region Key Tie-Ins
        protected override void _Initialize()
        {
            base._Initialize(); // DO NOT REMOVE
            //Initialize router daemons
            //Initialize OOB daemon
        }
        
        protected override void _Start()
        {
            base._Start(); // DO NOT REMOVE
            //Startup OOB daemon
            //Connect to routers
        }

        protected override void PrePulseLoop()
        {
            base.PrePulseLoop(); // DO NOT REMOVE
        }
        
        protected override void Pulse()
        {
            base.Pulse(); // DO NOT REMOVE
            //Pulse router daemons
            //* Parse awaiting input from routers into packets
            //* Handle any I3-specific authentication/ucacheing packets
            //* Dispatch remaining packets via methods/events tied in with mud server via interfaces

            //Pulse OOB daemons
            // ------- ...... --------
        }

        protected override void PostPulseLoop()
        {
            base.PostPulseLoop(); // DO NOT REMOVE
        }

        protected override void _Stop()
        {
            base._Stop(); // DO NOT REMOVE
        }
        #endregion

        public void Shutdown(int restartTime)
        {
            //Shutdown router connection manually
            this._Stop();
        }

        #region INetworkSystem Members

        INetworkConnection[] INetworkSystem.GetConnections()
        {
            //TODO: Add code that will traverse all connection daemons and return connection handles
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion

        #region INetworkSystem Members


        public IConnectionListener[] GetConnectionListeners()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion
    }
}
